<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="UTF-8" />
    <title>amis demo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1"
    />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <link rel="stylesheet" href="./assets/amis-sdk/sdk.css" />
    <link rel="stylesheet" href="./assets/amis-sdk/helper.css" />
    <!-- 从 1.1.0 开始 sdk.css 将不支持 IE 11，如果要支持 IE11 请引用这个 css，并把前面那个删了 -->
    <!-- <link rel="stylesheet" href="sdk-ie11.css" /> -->
    <!-- 不过 amis 开发团队几乎没测试过 IE 11 下的效果，所以可能有细节功能用不了，如果发现请报 issue -->
    <style>
      html,
      body,
      .app-wrapper {
        position: relative;
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
      }
    </style>
  </head>
  <body>
    <div id="root" class="app-wrapper"></div>
	<button onclick="test()">点击调试</button>
	<button onclick="test2()">点击调试-設置选中</button>
    <script src="./assets/amis-sdk/sdk.js"></script>
    <script type="text/javascript">
	var amis=null;
	var amisScoped=null;
      (function () {
         amis = amisRequire('amis/embed');
        // 通过替换下面这个配置来生成不同页面
        let amisJSON = {
			  "type": "page",
			  "name": "page1",
			  "body": {
				"type": "form",
				"name": "form1",
				"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
				"body": [
				  {
					"label": "表格形式",
					"type": "transfer",
					"name": "transfer1",
					"selectMode": "table",
					"columns": [
					  {
						"name": "label",
						"label": "英雄"
					  },
					  {
						"name": "position",
						"label": "位置"
					  }
					],
					"options": [
					  {
						"label": "诸葛亮",
						"value": "zhugeliang",
						"position": "中单"
					  },
					  {
						"label": "曹操",
						"value": "caocao",
						"position": "上单"
					  },
					  {
						"label": "钟无艳",
						"value": "zhongwuyan",
						"position": "上单"
					  },
					  {
						"label": "李白",
						"value": "libai",
						"position": "打野"
					  },
					  {
						"label": "韩信",
						"value": "hanxin",
						"position": "打野"
					  },
					  {
						"label": "云中君",
						"value": "yunzhongjun",
						"position": "打野"
					  }
					]
				  }
				]
			  }
			};
			
         amisScoped = amis.embed('#root', amisJSON);
      })();
	  
	  function getVal1(){
	     compInstance1=amisScoped.getComponentByName("email")
		let SelectedVaule=compInstance1.getValues()
		 console.log("getVal1 SelectedVaule="+SelectedVaule)
	  }
	  function getVal2(){
	     compInstance1=amisScoped.getComponentByName("form1")
		 let SelectedVaule=compInstance1.getValues()
		 console.log("getVal2 SelectedVaule="+SelectedVaule)
	  }
	  function getVal3(){

	    let compInstance1=amisScoped.getComponentByName("page1.form1")
		 let SelectedVaule=compInstance1.getValues()
		 console.log("getVal3 SelectedVaule="+JSON.stringify(SelectedVaule))
	  }	 
	  
	  function setVal1(){
	  	     debugger ;
	    let compInstance1=amisScoped.getComponentByName("page1.form1")
		//compInstance1.setValues("transfer1","caocao,zhugeliang,zhongwuyan,libai")
		compInstance1.setValues({'transfer1': 'caocao,zhugeliang,zhongwuyan,libai'})
         console.log("setVal1 =")
	  }	 

     function test(){
	   debugger ;
	   //getVal1();
	   //getVal2();
	   getVal3();
      }	 
	  
	  function test2(){
	    setVal1();
	  }
    </script>
  </body>
</html>